<%--
    Document   : addBook
    Created on : 30-Mar-2011, 18:18:53
    Author     : Thomas
--%>

<%@page import="MailinglistPackage.MailingList"%>
<%@page import="MailinglistPackage.MailingListService"%>
<%@page import="WishlistPackage.WishList"%>
<%@page import="WishlistPackage.WishListService"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<jsp:useBean id="sendMailBean" class="beans_pkg.sendMailBean" scope="page"/>
<jsp:setProperty name="sendMailBean" property="*"/>
<jsp:useBean id="member" class="login.userDBDriver" scope="session"/>

<%@ include file="header.jsp" %>

<!-- Content -->

<div id="container">
	<div id="content" role="main">
            <p>Subject: <%= sendMailBean.getSubject() %><br />
            Body: <%= sendMailBean.getBody() %><br /></p>

            <p></p><h2>Log:</h2>

            <%

            MailingList r = new MailingListService().getMailingListPort();
            out.println(r.sendEmail(sendMailBean.getSubject(), sendMailBean.getBody(), "Group9"));
            /*
            int answercat = member.createCategoryDB("userDB");
            int answer1 = member.databaseConnect("userDB");
            out.println("<textarea name='body' rows='10' cols='80'>");
            String[] userArray = member.getAllUsers();
            if(!userArray[0].contains("File not read") && !userArray[0].contains("Client not connected") ){
                for(int i=0; i<userArray.length; i++){
                    String[] userData = userArray[i].split("\t");
                    String loggedInUser = (String) session.getAttribute("loggedin_username");
                    if(!userData[0].contains("admin") && !userData[0].contains(loggedInUser)){

                        //Do maillist service for each user
                        out.println("User: " + userData[0] + " - Wishlist Service is currently down, please try again later!");
                    }
                }
            }
            else{
                out.println("<option><font color='red'>Error connecting to User Database!</font></option>");
            }
            out.println("</textarea>"); */
            %>
            <p><br/><a href="adminPage.jsp">Return</a></p>
        </div><!-- #content -->
</div><!-- #container -->

<%@ include file="sidebar.jsp" %>

<!-- /Content -->

<%@ include file="footer.jsp" %>